﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Office.Interop.Word;

namespace WFL.Office.Word
{
    public class TableRows
    {

        public TableRow this[int index]
        {
            get { return new TableRow(_rows[index]) { Table = Table }; }
        }

        public int Count
        {
            get { return _rows.Count; }
        }

        public float Height
        {
            get { return _rows.Height; }
            set { _rows.Height = value; }
        }

        public RowHeightRule HeightRule
        {
            get { return (RowHeightRule)_rows.HeightRule; }
            set { _rows.HeightRule = (WdRowHeightRule)value; }
        }

        public RowAlignment Alignment
        {
            get { return (RowAlignment)_rows.Alignment; }
            set { _rows.Alignment = (WdRowAlignment)value; }
        }

        /// <summary>
        /// 文字环绕
        /// </summary>
        public bool WrapAroundText
        {
            get { return _rows.WrapAroundText == -1; }
            set { _rows.WrapAroundText = value ? -1 : 0; }
        }

        private Rows _rows;

        public WordTable Table
        {
            get;
            internal set;
        }

        internal TableRows(Rows rows)
        {
            _rows = rows;
        }

        public TableRow Add(TableRow beforeRow = null)
        {
            object beforeRowArg = beforeRow != null ? beforeRow._row : Type.Missing;
            return new TableRow(_rows.Add(ref beforeRowArg)) { Table = Table };
        }
    }
}
